package com.hxt.framework.utils;

import java.util.HashSet;
import java.util.Set;

import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

public class PinyinUtils {
	static String CodeData = "cjwgnspgcenegypbtwxzdxykygtpjnmjqmbsgzscyjsyyfpggbzgydywjkgaljswkbjqhyjwpdzlsgmrybywwccgznkydgttngjeyekzydcjnmcylqlypyqbqrpzslwbdgkjfyxjwcltbncxjjjjcxdtqsqzycdxxhgckbphffsspybgmxjbbyglbhlssmzmpjhsojnghdzcdklgjhsgqzhxqgkezzwymcscjnyetxadzpmdssmzjjqjyzcjjfwqjbdzbjgdnzcbwhgxhqkmwfbpbqdtjjzkqhylcgxfptyjyyzpsjlfchmqshgmmxsxjpkdcmbbqbefsjwhwwgckpylqbgldlcctnmaeddksjngkcsgxlhzaybdbtsdkdylhgymylcxpycjndqjwxqxfyyfjlejbzrwccqhqcsbzkymgplbmcrqcflnymyqmsqtrbcjthztqfrxchxmcjcjlxqgjmshzkbswxemdlckfsydsglycjjssjnqbjctyhbftdcyjdgwyghqfrxwckqkxebpdjpxjqsrmebwgjlbjslyysmdxlclqkxlhtjrjjmbjhxhwywcbhtrxxglhjhfbmgykldyxzpplggpmtcbbajjzyljtyanjgbjflqgdzyqcaxbkclecjsznslyzhlxlzcghbxzhznytdsbcjkdlzayffydlabbgqszkggldndnyskjshdlxxbcghxyggdjmmzngmmccgwzszxsjbznmlzdthcqydbdllscddnlkjyhjsycjlkohqasdhnhcsgaehdaashtcplcpqybsdmpjlpcjaqlcdhjjasprchngjnlhlyyqyhwzpnccgwwmzffjqqqqxxaclbhkdjxdgmmydjxzllsygxgkjrywzwyclzmcsjzldbndcfcxyhlschycjqppqagmnyxpfrkssbjlyxyjjglnscmhcwwmnzjjlhmhchsyppttxrycsxbyhcsmxjsxnbwgpxxtaybgajcxlypdccwqocwkccsbnhcpdyznbcyytyckskybsqkkytqqxfcwchcwkelcqbsqyjqcclmthsywhmktlkjlychwheqjhtjhppqpqscfymmcmgbmhglgsllysdllljpchmjhwljcyhzjxhdxjlhxrswlwzjcbxmhzqxsdzpmgfcsglsdymjshxpjxomyqknmyblrthbcftpmgyxlchlhlzylxgsssscclsldclepbhshxyyfhbmgdfycnjqwlqhjjcywjztejjdhfblqxtqkwhdchqxagtlxljxmsljhdzkzjecxjcjnmbbjcsfywkbjzghysdcpqyrsljpclpwxsdwejbjcbcnaytmgmbapclyqbclzxcbnmsggfnzjjbzsfqyndxhpcqkzczwalsbccjxpozgwkybsgxfcfcdkhjbstlqfsgdslqwzkxtmhsbgzhjcrglyjbpmljsxlcjqqhzmjczydjwbmjklddpmjegxyhylxhlqyqhkycwcjmyhxnatjhyccxzpcqlbzwwwtwbqcmlbmynjcccxbbsnzzljpljxyztzlgcldcklyrzzgqtgjhhgjljaxfgfjzslcfdqzlclgjdjcsnclljpjqdcclcjxmyzftsxgcgsbrzxjqqcczhgyjdjqqlzxjyldlbcyamcstylbdjbyregklzdzhldszchznwczcllwjqjjjkdgjcolbbzppglghtgzcygezmycnqcycyhbhgxkamtxyxnbskyzzgjzlqjdfcjxdygjqjjpmgwgjjjpkjsbgbmmcjssclpqpdxcdyykypcjddyygywchjrtgcnyqldkljczzgzccjgdyksgpzmdlcphnjafyzdjcnmwescsglbtzcgmsdllyxqsxsbljsbbsgghfjlwpmzjnlyywdqshzxtyywhmcyhywdbxbtlmswyyfsbjcbdxxlhjhfpsxzqhfzmqcztqcxzxrdkdjhnnyzqqfnqdmmgnydxmjgdhcdycbffallztdltfkmxqzdngeqdbdczjdxbzgsqqddjcmbkxffxmkdmcsychzcmljdjynhprsjmkmpcklgdbqtfzswtfgglyplljzhgjjgypzltcsmcnbtjbhfkdhbyzgkpbbymtdlsxsbnpdkleycjnycdykzddhqgsdzsctarlltkzlgecllkjljjaqnbdggghfjtzqjsecshalqfmmgjnlyjbbtmlycxdcjpldlpcqdhsycbzsckbzmsljflhrbjsnbrgjhxpdgdjybzgdlgcsezgxlblgyxtwmabchecmwyjyzlljjshlgndjlslygkdzpzxjyyzlpcxszfgwyydlyhcljscmbjhblyjlycblydpdqysxktbytdkdxjypcnrjmfdjgklccjbctbjddbblblcdqrppxjcglzcshltoljnmdddlngkaqakgjgyhheznmshrphqqjchgmfprxcjgdychghlyrzqlcngjnzsqdkqjymszswlcfqjqxgbggxmdjwlmcrnfkkfsyyljbmqammmycctbshcptxxzzsmphfshmclmldjfyqxsdyjdjjzzhqpdszglssjbckbxyqzjsgpsxjzqznqtbdkwxjkhhgflbcsmdldgdzdblzkycqnncsybzbfglzzxswmsccmqnjqsbdqsjtxxmbldxcclzshzcxrqjgjylxzfjphymzqqydfqjjlcznzjcdgzygcdxmzysctlkphtxhtlbjxjlxscdqccbbqjfqzfsltjbtkqbsxjjljchczdbzjdczjccprnlqcgpfczlclcxzdmxmphgsgzgszzqjxlwtjpfsyaslcjbtckwcwmytcsjjljcqlwzmalbxyfbpnlschtgjwejjxxglljstgshjqlzfkcgnndszfdeqfhbsaqdgylbxmmygszldydjmjjrgbjgkgdhgkblgkbdmbylxwcxyttybkmrjjzxqjbhlmhmjjzmqasldcyxyqdlqcafywyxqhz";

	public static Set<String> pinyinset = new HashSet<String>();

	static {
		{
			pinyinset.add("A");
			pinyinset.add("AI");
			pinyinset.add("AN");
			pinyinset.add("ANG");
			pinyinset.add("AO");
			pinyinset.add("BA");
			pinyinset.add("BAI");
			pinyinset.add("BAN");
			pinyinset.add("BANG");
			pinyinset.add("BAO");
			pinyinset.add("BEI");
			pinyinset.add("BEN");
			pinyinset.add("BENG");
			pinyinset.add("BI");
			pinyinset.add("BIAN");
			pinyinset.add("BIAO");
			pinyinset.add("BIE");
			pinyinset.add("BIN");
			pinyinset.add("BING");
			pinyinset.add("BO");
			pinyinset.add("BU");
			pinyinset.add("CA");
			pinyinset.add("CAI");
			pinyinset.add("CAN");
			pinyinset.add("CANG");
			pinyinset.add("CAO");
			pinyinset.add("CE");
			pinyinset.add("CEN");
			pinyinset.add("CENG");
			pinyinset.add("CHA");
			pinyinset.add("CHAI");
			pinyinset.add("CHAN");
			pinyinset.add("CHANG");
			pinyinset.add("CHAO");
			pinyinset.add("CHE");
			pinyinset.add("CHEN");
			pinyinset.add("CHENG");
			pinyinset.add("CHONG");
			pinyinset.add("CHOU");
			pinyinset.add("CHU");
			pinyinset.add("CHUA");
			pinyinset.add("CHUAI");
			pinyinset.add("CHUAN");
			pinyinset.add("CHUANG");
			pinyinset.add("CHUI");
			pinyinset.add("CHUN");
			pinyinset.add("CHUO");
			pinyinset.add("CONG");
			pinyinset.add("COU");
			pinyinset.add("CU");
			pinyinset.add("CUAN");
			pinyinset.add("CUI");
			pinyinset.add("CUN");
			pinyinset.add("CUO");
			pinyinset.add("DA");
			pinyinset.add("DAI");
			pinyinset.add("DAN");
			pinyinset.add("DANG");
			pinyinset.add("DAO");
			pinyinset.add("DE");
			pinyinset.add("DEI");
			pinyinset.add("DEN");
			pinyinset.add("DENG");
			pinyinset.add("DI");
			pinyinset.add("DIAN");
			pinyinset.add("DIAO");
			pinyinset.add("DIE");
			pinyinset.add("DING");
			pinyinset.add("DIU");
			pinyinset.add("DONG");
			pinyinset.add("DOU");
			pinyinset.add("DU");
			pinyinset.add("DUAN");
			pinyinset.add("DUI");
			pinyinset.add("DUN");
			pinyinset.add("DUO");
			pinyinset.add("E");
			pinyinset.add("EI");
			pinyinset.add("EN");
			pinyinset.add("ENG");
			pinyinset.add("ER");
			pinyinset.add("FA");
			pinyinset.add("FAN");
			pinyinset.add("FANG");
			pinyinset.add("FEI");
			pinyinset.add("FEN");
			pinyinset.add("FENG");
			pinyinset.add("FO");
			pinyinset.add("FOU");
			pinyinset.add("FU");
			pinyinset.add("GA");
			pinyinset.add("GAI");
			pinyinset.add("GAN");
			pinyinset.add("GANG");
			pinyinset.add("GAO");
			pinyinset.add("GE");
			pinyinset.add("GEI");
			pinyinset.add("GEN");
			pinyinset.add("GENG");
			pinyinset.add("GONG");
			pinyinset.add("GOU");
			pinyinset.add("GU");
			pinyinset.add("GUA");
			pinyinset.add("GUAI");
			pinyinset.add("GUAN");
			pinyinset.add("GUANG");
			pinyinset.add("GUI");
			pinyinset.add("GUN");
			pinyinset.add("GUO");
			pinyinset.add("HA");
			pinyinset.add("HAI");
			pinyinset.add("HAN");
			pinyinset.add("HANG");
			pinyinset.add("HAO");
			pinyinset.add("HE");
			pinyinset.add("HEI");
			pinyinset.add("HEN");
			pinyinset.add("HENG");
			pinyinset.add("HONG");
			pinyinset.add("HOU");
			pinyinset.add("HU");
			pinyinset.add("HUA");
			pinyinset.add("HUAI");
			pinyinset.add("HUAN");
			pinyinset.add("HUANG");
			pinyinset.add("HUI");
			pinyinset.add("HUN");
			pinyinset.add("HUO");
			pinyinset.add("JI");
			pinyinset.add("JIA");
			pinyinset.add("JIAN");
			pinyinset.add("JIANG");
			pinyinset.add("JIAO");
			pinyinset.add("JIE");
			pinyinset.add("JIN");
			pinyinset.add("JING");
			pinyinset.add("JIONG");
			pinyinset.add("JIU");
			pinyinset.add("JU");
			pinyinset.add("JUAN");
			pinyinset.add("JUE");
			pinyinset.add("JUN");
			pinyinset.add("KA");
			pinyinset.add("KAI");
			pinyinset.add("KAN");
			pinyinset.add("KANG");
			pinyinset.add("KAO");
			pinyinset.add("KE");
			pinyinset.add("KEN");
			pinyinset.add("KENG");
			pinyinset.add("KONG");
			pinyinset.add("KOU");
			pinyinset.add("KU");
			pinyinset.add("KUA");
			pinyinset.add("KUAI");
			pinyinset.add("KUAN");
			pinyinset.add("KUANG");
			pinyinset.add("KUI");
			pinyinset.add("KUN");
			pinyinset.add("KUO");
			pinyinset.add("LA");
			pinyinset.add("LAI");
			pinyinset.add("LAN");
			pinyinset.add("LANG");
			pinyinset.add("LAO");
			pinyinset.add("LE");
			pinyinset.add("LEI");
			pinyinset.add("LENG");
			pinyinset.add("LI");
			pinyinset.add("LIA");
			pinyinset.add("LIAN");
			pinyinset.add("LIANG");
			pinyinset.add("LIAO");
			pinyinset.add("LIE");
			pinyinset.add("LIN");
			pinyinset.add("LING");
			pinyinset.add("LIU");
			pinyinset.add("LONG");
			pinyinset.add("LOU");
			pinyinset.add("LU");
			pinyinset.add("LU:");
			pinyinset.add("LUAN");
			pinyinset.add("LU:E");
			pinyinset.add("LUN");
			pinyinset.add("LUO");
			pinyinset.add("MA");
			pinyinset.add("MAI");
			pinyinset.add("MAN");
			pinyinset.add("MANG");
			pinyinset.add("MAO");
			pinyinset.add("ME");
			pinyinset.add("MEI");
			pinyinset.add("MEN");
			pinyinset.add("MENG");
			pinyinset.add("MI");
			pinyinset.add("MIAN");
			pinyinset.add("MIAO");
			pinyinset.add("MIE");
			pinyinset.add("MIN");
			pinyinset.add("MING");
			pinyinset.add("MIU");
			pinyinset.add("MO");
			pinyinset.add("MOU");
			pinyinset.add("MU");
			pinyinset.add("NA");
			pinyinset.add("NAI");
			pinyinset.add("NAN");
			pinyinset.add("NANG");
			pinyinset.add("NAO");
			pinyinset.add("NE");
			pinyinset.add("NEI");
			pinyinset.add("NEN");
			pinyinset.add("NENG");
			pinyinset.add("NI");
			pinyinset.add("NIAN");
			pinyinset.add("NIANG");
			pinyinset.add("NIAO");
			pinyinset.add("NIE");
			pinyinset.add("NIN");
			pinyinset.add("NING");
			pinyinset.add("NIU");
			pinyinset.add("NONG");
			pinyinset.add("NOU");
			pinyinset.add("NU");
			pinyinset.add("NU:");
			pinyinset.add("NUAN");
			pinyinset.add("NU:E");
			pinyinset.add("NUO");
			pinyinset.add("O");
			pinyinset.add("OU");
			pinyinset.add("PA");
			pinyinset.add("PAI");
			pinyinset.add("PAN");
			pinyinset.add("PANG");
			pinyinset.add("PAO");
			pinyinset.add("PEI");
			pinyinset.add("PEN");
			pinyinset.add("PENG");
			pinyinset.add("PI");
			pinyinset.add("PIAN");
			pinyinset.add("PIAO");
			pinyinset.add("PIE");
			pinyinset.add("PIN");
			pinyinset.add("PING");
			pinyinset.add("PO");
			pinyinset.add("POU");
			pinyinset.add("PU");
			pinyinset.add("QI");
			pinyinset.add("QIA");
			pinyinset.add("QIAN");
			pinyinset.add("QIANG");
			pinyinset.add("QIAO");
			pinyinset.add("QIE");
			pinyinset.add("QIN");
			pinyinset.add("QING");
			pinyinset.add("QIONG");
			pinyinset.add("QIU");
			pinyinset.add("QU");
			pinyinset.add("QUAN");
			pinyinset.add("QUE");
			pinyinset.add("QUN");
			pinyinset.add("RAN");
			pinyinset.add("RANG");
			pinyinset.add("RAO");
			pinyinset.add("RE");
			pinyinset.add("REN");
			pinyinset.add("RENG");
			pinyinset.add("RI");
			pinyinset.add("RONG");
			pinyinset.add("ROU");
			pinyinset.add("RU");
			pinyinset.add("RUAN");
			pinyinset.add("RUI");
			pinyinset.add("RUN");
			pinyinset.add("RUO");
			pinyinset.add("SA");
			pinyinset.add("SAI");
			pinyinset.add("SAN");
			pinyinset.add("SANG");
			pinyinset.add("SAO");
			pinyinset.add("SE");
			pinyinset.add("SEN");
			pinyinset.add("SENG");
			pinyinset.add("SHA");
			pinyinset.add("SHAI");
			pinyinset.add("SHAN");
			pinyinset.add("SHANG");
			pinyinset.add("SHAO");
			pinyinset.add("SHE");
			pinyinset.add("SHEI");
			pinyinset.add("SHEN");
			pinyinset.add("SHENG");
			pinyinset.add("SHOU");
			pinyinset.add("SHU");
			pinyinset.add("SHUA");
			pinyinset.add("SHUAI");
			pinyinset.add("SHUAN");
			pinyinset.add("SHUANG");
			pinyinset.add("SHUI");
			pinyinset.add("SHUN");
			pinyinset.add("SHUO");
			pinyinset.add("SONG");
			pinyinset.add("SOU");
			pinyinset.add("SU");
			pinyinset.add("SUAN");
			pinyinset.add("SUI");
			pinyinset.add("SUN");
			pinyinset.add("SUO");
			pinyinset.add("TA");
			pinyinset.add("TAI");
			pinyinset.add("TAN");
			pinyinset.add("TANG");
			pinyinset.add("TAO");
			pinyinset.add("TE");
			pinyinset.add("TENG");
			pinyinset.add("TI");
			pinyinset.add("TIAN");
			pinyinset.add("TIAO");
			pinyinset.add("TIE");
			pinyinset.add("TING");
			pinyinset.add("TONG");
			pinyinset.add("TOU");
			pinyinset.add("TU");
			pinyinset.add("TUAN");
			pinyinset.add("TUI");
			pinyinset.add("TUN");
			pinyinset.add("TUO");
			pinyinset.add("WA");
			pinyinset.add("WAI");
			pinyinset.add("WAN");
			pinyinset.add("WANG");
			pinyinset.add("WEI");
			pinyinset.add("WEN");
			pinyinset.add("WENG");
			pinyinset.add("WO");
			pinyinset.add("WU");
			pinyinset.add("XI");
			pinyinset.add("XIA");
			pinyinset.add("XIAN");
			pinyinset.add("XIANG");
			pinyinset.add("XIAO");
			pinyinset.add("XIE");
			pinyinset.add("XIN");
			pinyinset.add("XING");
			pinyinset.add("XIONG");
			pinyinset.add("XIU");
			pinyinset.add("XU");
			pinyinset.add("XUAN");
			pinyinset.add("XUE");
			pinyinset.add("XUN");
			pinyinset.add("YA");
			pinyinset.add("YAN");
			pinyinset.add("YANG");
			pinyinset.add("YAO");
			pinyinset.add("YE");
			pinyinset.add("YI");
			pinyinset.add("YIN");
			pinyinset.add("YING");
			pinyinset.add("YONG");
			pinyinset.add("YOU");
			pinyinset.add("YU");
			pinyinset.add("YUAN");
			pinyinset.add("YUE");
			pinyinset.add("YUN");
			pinyinset.add("ZA");
			pinyinset.add("ZAI");
			pinyinset.add("ZAN");
			pinyinset.add("ZANG");
			pinyinset.add("ZAO");
			pinyinset.add("ZE");
			pinyinset.add("ZEI");
			pinyinset.add("ZEN");
			pinyinset.add("ZENG");
			pinyinset.add("ZHA");
			pinyinset.add("ZHAI");
			pinyinset.add("ZHAN");
			pinyinset.add("ZHANG");
			pinyinset.add("ZHAO");
			pinyinset.add("ZHE");
			pinyinset.add("ZHEI");
			pinyinset.add("ZHEN");
			pinyinset.add("ZHENG");
			pinyinset.add("ZHONG");
			pinyinset.add("ZHOU");
			pinyinset.add("ZHU");
			pinyinset.add("ZHUA");
			pinyinset.add("ZHUAI");
			pinyinset.add("ZHUAN");
			pinyinset.add("ZHUANG");
			pinyinset.add("ZHUI");
			pinyinset.add("ZHUN");
			pinyinset.add("ZHUO");
			pinyinset.add("ZONG");
			pinyinset.add("ZOU");
			pinyinset.add("ZU");
			pinyinset.add("ZUAN");
			pinyinset.add("ZUI");
			pinyinset.add("ZUN");
			pinyinset.add("ZUO");

			pinyinset.add("ZI");
			pinyinset.add("CI");
			pinyinset.add("SI");
			pinyinset.add("RI");
			pinyinset.add("ZHI");
			pinyinset.add("CHI");
			pinyinset.add("SHI");
			pinyinset.add("WU");
			pinyinset.add("YE");
			pinyinset.add("YU");
			pinyinset.add("YUE");
			pinyinset.add("YI");
			pinyinset.add("YIN");
			pinyinset.add("YING");
			pinyinset.add("YUN");
			pinyinset.add("YUAN");

		}
	}

	public static boolean hasHanzi(String s) {
		return s.length() != s.getBytes().length;
	}

	public static int getCode(String c) {
		try {
			byte[] i = c.getBytes("GBK");
			if (i.length > 1) {
				int j = 0;
				return (i[j] + 96) * 100 + i[j + 1] + 96;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return -1;
	}

	public static char code2firstchar(int GBCode) {
		if (GBCode >= 1601 && GBCode < 1637)
			return 'a';
		else if (GBCode >= 1637 && GBCode < 1833)
			return 'b';
		else if (GBCode >= 1833 && GBCode < 2078)
			return 'c';
		else if (GBCode >= 2078 && GBCode < 2274)
			return 'd';
		else if (GBCode >= 2274 && GBCode < 2302)
			return 'e';
		else if (GBCode >= 2302 && GBCode < 2433)
			return 'f';
		else if (GBCode >= 2433 && GBCode < 2594)
			return 'g';
		else if (GBCode >= 2594 && GBCode < 2787)
			return 'h';
		else if (GBCode >= 2787 && GBCode < 3106)
			return 'j';
		else if (GBCode >= 3106 && GBCode < 3212)
			return 'k';
		else if (GBCode >= 3212 && GBCode < 3472)
			return 'l';
		else if (GBCode >= 3472 && GBCode < 3635)
			return 'm';
		else if (GBCode >= 3635 && GBCode < 3722)
			return 'n';
		else if (GBCode >= 3722 && GBCode < 3730)
			return 'o';
		else if (GBCode >= 3730 && GBCode < 3858)
			return 'p';
		else if (GBCode >= 3858 && GBCode < 4027)
			return 'q';
		else if (GBCode >= 4027 && GBCode < 4086)
			return 'r';
		else if (GBCode >= 4086 && GBCode < 4390)
			return 's';
		else if (GBCode >= 4390 && GBCode < 4558)
			return 't';
		else if (GBCode >= 4558 && GBCode < 4684)
			return 'w';
		else if (GBCode >= 4684 && GBCode < 4925)
			return 'x';
		else if (GBCode >= 4925 && GBCode < 5249)
			return 'y';
		else if (GBCode >= 5249 && GBCode <= 5589)
			return 'z';
		else if (GBCode >= 5601 && GBCode <= 8794) {
			int n = ((GBCode / 100) - 56) * 94;
			// int m=(GBCode/100)*100;
			n += (GBCode - (GBCode / 100) * 100);
			return CodeData.charAt(n - 1);
		}
		return '-';
	}

	public static char firstchar(String str) {
		if (str.length() < 1)
			return '-';
		int GBCode = getCode(str);
		if (GBCode == -1) {
			return str.toUpperCase().charAt(0);
		}
		return code2firstchar(GBCode);
	}

	public static String firstchar2(String str) {
		if (str == null)
			return null;
		if (str.indexOf(" ") > 0) {
			str = str.replaceAll(" ", "");
		}
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < str.length(); i++) {
			String s = str.substring(i, i + 1);
			if (hasHanzi(s)) {
				sb.append(firstchar(s));
			} else {
				sb.append(s);
			}
		}
		return sb.toString().toUpperCase();
	}

	static boolean isHz(int c) {
		return (c >= 1601 && c <= 8794);
	}

	/**
	 * 
	 * @Title: isContainNumeric
	 * @Description: 判断字符串是否包含数字
	 * @param str
	 * @return
	 * @return: boolean
	 */
	public static boolean isContainNumeric(String str) {
		for (int i = 0; i < str.length(); i++) {
			System.out.println(str.charAt(i));
			if (Character.isDigit(str.charAt(i))) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 
	 * @Title: isNumeric
	 * @Description: 判断字符串是否为数字
	 * @param str
	 * @return
	 * @return: boolean
	 */
	public static boolean isNumeric(String str) {
		for (int i = 0; i < str.length(); i++) {
			System.out.println(str.charAt(i));
			if (!Character.isDigit(str.charAt(i))) {
				return false;
			}
		}
		return true;
	}

	public static String getPinyin(String name) {
		String n2 = name;
		return PinyinUtils.firstchar2(n2);
	}
	
	public static String converterToFirstSpellOne(String chines) {
		String pinyinName = "";
		char nameChar = chines.toCharArray()[0];
		HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
		defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
		defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
		if (nameChar > 128) {
			try {

				pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar, defaultFormat)[0].charAt(0);
			} catch (BadHanyuPinyinOutputFormatCombination e) {
				e.printStackTrace();
			}
		} else {
			pinyinName += nameChar;
		}
		return pinyinName;
	}

	public static String getPingYin(String src) {
		char[] t1 = null;
		t1 = src.toCharArray();
		String[] t2 = new String[t1.length];
		HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat();
		t3.setCaseType(HanyuPinyinCaseType.LOWERCASE);
		t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
		t3.setVCharType(HanyuPinyinVCharType.WITH_V);
		String t4 = "";
		int t0 = t1.length;
		try {
			for (int i = 0; i < t0; i++) {
				// 判断是否为汉字字符
				if (java.lang.Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+")) {
					t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);
					t4 += t2[0];
				} else {
					t4 += java.lang.Character.toString(t1[i]);
				}
			}
			return t4;
		} catch (BadHanyuPinyinOutputFormatCombination e1) {
			e1.printStackTrace();
		}
		return t4;
	}

	public static String getPinYinHeadChar(String str) {

		String convert = "";
		for (int j = 0; j < str.length(); j++) {
			char word = str.charAt(j);
			String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
			if (pinyinArray != null) {
				convert += pinyinArray[0].charAt(0);
			} else {
				convert += word;
			}
		}
		return convert;
	}

	public static void main(String[] args) {
		System.out.println(firstchar("齿 轮 机 油管 出"));
	}
}
